<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class autoloader {
    private function __construct() {
        spl_autoload_register(array($this, 'loader'));
    }
    
    public static function init(){
      new autoloader();
    }
    
    private function loader($className) {
      
      $classname  = strtolower($className);
      
      $fileName   = PATH_CLASS."$classname.class.php";
      
      if(file_exists($fileName)){
        require_once $fileName;
      } else if ($classname=='database'){
        require_once(PATH_LIB.'database.php');
      }
      else {
        return new stdClass();
      }
    }
}

